import time
# 使用闭包实现不修改源代码的前提下修改日志信息
def emailLog(fun):
    with open('./a1.txt','a',encoding='utf-8') as f:
        f.write("调用了:\t")
        f.write(fun.__name__)
        f.write("\t调用时间:{}\n".format(time.asctime()))

def fun1():
    print("我是fun1")
def fun2():
    print("我是fun2")

def writeOut(fun):
    def writeIn():
        fun()
        emailLog(fun)
        print("调用了"+fun.__name__)
    return writeIn

myfun1=writeOut(fun1)
myfun1()
time.sleep(2)
myfun2=writeOut(fun2)
myfun2()